//
//  BSMotion.h
//  BASE_LIB
//
//  Created by shiji on 2018/10/27.
//  Copyright © 2018年 shiji. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreMotion/CoreMotion.h>

NS_ASSUME_NONNULL_BEGIN

@interface BSMotion : NSObject
@property (nonatomic, strong, readonly) CMAccelerometerData *accelerometerData;
@property (readonly, nullable, strong, nonatomic) CMGyroData *gyroData;
@property (readonly, nullable, strong, nonatomic) CMMagnetometerData *magnetometerData;
@property (readonly, nullable, strong, nonatomic) CMDeviceMotion *deviceMotion;
@property (nonatomic, assign) NSTimeInterval accelerometerInterval;
@property (assign, nonatomic) NSTimeInterval gyroInterval;
@property (assign, nonatomic) NSTimeInterval magnetometerInterval;
+ (instancetype)shared;
// accelerometer
- (BOOL)isAccelerometerAvailable;
- (BOOL)isAccelerometerActive;
- (void)startAccelerometerUpdates;
- (void)startAccelerometer:(NSOperationQueue *)queue withHandler:(CMAccelerometerHandler)handler;
- (void)stopAcceloremeter;

// groy
- (BOOL)isGroyAvailable;
- (BOOL)isGyroActive;
- (void)startGyroUpdates;
- (void)startGyro:(NSOperationQueue *)queue withHandler:(CMGyroHandler)handler;
- (void)stopGyro;

// magnetometer
- (BOOL)isMagnetometerAvailable;
- (BOOL)isMagnetometerActive;
- (void)startMagnetometerUpdates;
- (void)startMagnetometer:(NSOperationQueue *)queue withHandler:(CMMagnetometerHandler)handler;
- (void)stopMagnetometer;

// DeviceMotion
- (BOOL)isDeviceMotionAailable;
- (BOOL)isDeviceMotionActive;
- (void)startDeviceMotion;
- (void)startDeviceMotion:(NSOperationQueue *)queue withHandler:(CMDeviceMotionHandler)handler;
- (void)stopDeviceMotion;
@end

NS_ASSUME_NONNULL_END
